<?php
/**
 * Member detail
 * แสดงรายละเอียดของ member พร้อม form สำหรับแก้ไข
 * @package Member
 * @subpackage View
 * @category view
 */
require('right_bar.php');
$x['AddTitle'] .= $this->lang->line('mem.80.memberdetail');

/* Load CSS */
$tmp = array('a:c:validationEngine.jquery', 'a:c:form_signup', 'a:c:excite-bike:jqui187', 'a:c:table-style','a:c:fancybox134');
$x['AddHead'] .= $this->bee->AddCss($tmp);
unset($tmp);
// Load CSS
/* Load JavaScript*/
  $tmp = array('a:j:jquery.validationEngine-en', 'a:j:jquery.validationEngine','a:j:fancybox134.pack');
  $bf['AddFoot'] .= $this->bee->AddJava($tmp);
  unset($tmp);
  // Load JavaScript 

$x['AddCss'] .= '
#ban_reason{
    width: 250px;
}
input[type=text]{
    width: 250px;
}
';
$bf['AddHeadJquery'] .= '
    $(".form_blue").validationEngine();
    $(".bbox").fancybox();
    $("#membergroup").change( function() {
        
        $.get("'.site_url('member/admin/change_group/'.$member->user_id).'/"+$(this).val());
        $(this).next().show().delay(1200).fadeOut(800);
    });
    ';

$x['headlink'] = $this->lang->line('mem.80.memberdetail');

$this->admin->view('_head', $x);
unset($x);
?>
<div id="rightnow">
    <h3 class="reallynow">
        <span><?php echo $this->lang->line("mem.81.profile"); ?></span>
        <?php 
            if(!$member->banned){
                //echo anchor(current_url().'#reasonban',$this->lang->line('mem.82.suspend'),'class="bsp bicon s-stop bbox"');
                echo '<a href="#reasonban" class="bsp bicon s-stop bbox">'.$this->lang->line('mem.82.suspend').'</a>';
            } else {
                echo anchor('member/admin/unban_user/'.$member->user_id,$this->lang->line('mem.94.unsuspend'),'class="bsp bicon s-user_go"');
            }?>
        <?php echo anchor('member/admin/delete_member/'.$member->user_id,$this->lang->line('mem.83.delete'),'class="bsp bicon s-cancel" onclick="javascript:return confirm(\''.$this->lang->line("mem.95.confirmdelete").'\')"')?>
        <?php
            if(!$member->activated){
                echo anchor('member/admin/activate_user/'.$member->user_id,$this->lang->line('mem.92.activate'),'class="bsp bicon s-tick"');
            }
            ?>
        <?php
        if($member->activated){
                echo anchor('member/admin/reset_password/'.$member->user_id,$this->lang->line('mem.96.resetpass'),'class="bsp bicon s-control_repeat"');
            }
        ?>
        <br />
    </h3>

</div>
<table class="btable">
    <tbody>
         <tr>
            <th><?php echo $this->lang->line('mem.60.id'); ?></th>
            <td><?php echo $member->user_id?></td>
            <th><?php echo $this->lang->line('mem.61.user'); ?></th>
            <td><?php echo $member->username?></td>
         </tr>
       
        <tr>
            <th><?php echo $this->lang->line('mem.62.email'); ?></th>
            <td><?php echo $member->email?></td>

            <th><?php echo $this->lang->line('mem.63.group'); ?></th>
            <td><?php echo $group[$member->memgroup]?>
            <select name="memgroup" id="membergroup">
                <?php foreach($group as $k => $v){
                    if($k == 120 || $k == 30) continue; //except Super admin , Guest
                    if($k == $member->memgroup){
                        echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
                    } else {
                        echo '<option value="'.$k.'">'.$v.'</option>';
                    }
                }?>
            </select><span style="background-color: yellow;display:none;">update แล้ว</span>
            </td>
        </tr>

        <tr>
            <th><?php echo $this->lang->line('mem.64.active'); ?></th>
            <td><?php echo $member->activated?>
            <?php
            if(!$member->activated){
                echo anchor('member/admin/activate_user/'.$member->user_id,$this->lang->line('mem.92.activate'),'class="bsp bicon s-tick"');
            }
            ?></td>
            <th><?php echo $this->lang->line('mem.86.last_ip'); ?></th>
            <td><?php echo $member->last_ip?></td>
        </tr>
        <tr>
            <th><?php echo $this->lang->line('mem.84.banned'); ?></th>
            <td><?php echo $member->banned?></td>
            <th><?php echo $this->lang->line('mem.85.banreason'); ?></th>
            <td><?php echo $member->ban_reason?></td>
        </tr>
        <tr>
            <th><?php echo $this->lang->line('mem.87.last_login'); ?></th>
            <td><?php echo $member->last_login?></td>
            <th><?php echo $this->lang->line('mem.88.created'); ?></th>
            <td><?php echo $member->created?></td>
        </tr>
        <tr>
            <th><?php echo $this->lang->line('mem.89.modified'); ?></th>
            <td><?php echo $member->modified?></td>
            <th> </th>
            <td> </td>
        </tr>
        <tr>
            <td colspan="4"><?php echo $this->lang->line('mem.81.profile'); ?></td>
        </tr>
        </tbody>
<form action="<?php echo site_url('member/admin/change_profile/'.$member->user_id)?>" method="post">

        <tfoot>

        <?php
        
        foreach($member as $k => $v){
            //skip
            if(preg_match("/(password|id|username|email|activated|ban|ban_reason|last_login|last_ip|created|modified|memgroup)/i", $k)) continue;
           ?>
        <tr>
            <td colspan="2"><?php echo $this->lang->line('mem.90.'.$k); ?></td>
            <td colspan="2"><input type="text" name="<?php echo $k?>" value="<?php echo $v?>" /></td>
        </tr>
        <?php
        }?>
        <tr>
            <th colspan="4"><input type="submit" name="submit" value="submit" onclick="javascript:return confirm('<?php echo $this->lang->line("mem.91.update")?>')" /></th>

        </tr>
        
    </tfoot>
    </form>
</table>
<div style="display:none;">
<div id="reasonban">
    <form action="<?php echo site_url('member/admin/ban_user/'.$member->id)?>" method="post" class="form_blue">
        <fieldset>
            <legend><?php echo $this->lang->line('mem.93.inputreason');?></legend>
            <label for="ban_reason"><?php echo $this->lang->line('mem.85.banreason');?></label>
            <input type="text" name="ban_reason" id="ban_reason" class="validate[required,length[3,254]]" />
            <input type="submit" name="submit" value="Ban" />
        </fieldset>
    </form>
</div>
    </div>
<?php
        $this->admin->view('_foot', $bf);
        unset($bf);
?>